/**
 * 
 */
package com.jcore1.chapter6;

/**
 * @author Administrator
 *
 */
public class ArrayAlg {

	public static class Pair {
		
		private double first;
		
		private double second;

		public double getFirst() {
			return first;
		}

		public void setFirst(double first) {
			this.first = first;
		}

		public double getSecond() {
			return second;
		}

		public void setSecond(double second) {
			this.second = second;
		}

		public Pair(double first, double second) {
			super();
			this.first = first;
			this.second = second;
		}

	}
	
	public static Pair minmax(double[] vals) {
		double min = vals[0];
		double max = vals[0];
		for (double d : vals) {
			if (min > d) {
				min = d;
			}
			if (max < d) {
				max = d;
			}
		}
		
		return new Pair(min, max);
	}
}
